/**
 * @file       file_lock.cpp
 * @brief      
 * @author     LiuJkun
 * @version    1.0.0
 */

/*********************************************************************
 *  LiuJikun   01/16/10      Initial Version
 *********************************************************************/

#include	<stdlib.h>
#include    <stdio.h>
#include	<sys/stat.h>
#include	<fcntl.h>
#include	<unistd.h>
#include	<string.h>
#include	<stdint.h>
#include	<errno.h>
#include	"file_lock.h"

/**
 * @brief 
 */
int main ( int argc, char *argv[] )
{
    int fd = open( "data", O_RDWR ); 
    printf ( "fd = %d\n", fd );
    int flags = fcntl( fd, F_GETFL );
    printf ( "flags = %x, O_RDWD = %d\n", flags & O_ACCMODE, O_RDWR );
    lock_read( fd, 0, 3 );
//    sleep(10);
    unlock_file( fd, 0, 3 );
    close( fd );
    return EXIT_SUCCESS;
}				// ----------  end of function main  ----------
